# Generate streamlit application entitled "Momentum analysis tool" with 6 tabs. # The first tab named "Strgy Analysis" has 2 rows. # On the first row are 5 elements laid out horizontally # The first element is a pulldown labeled "universe" with items labeled "D30", "N100", "SP500", "R1000" and "FAANNG" that defaults to "FAANNG". # The second element is a text field labeled "lags" that allows me to enter a list of comma delimited numbers and initialized with the string "1,3,6,12", # The third element is a pulldown labeled "member count" with 6 items labeled 1-6 that defaults to 6. # The fourth element is a text field labeled "months back" initialized to 12. # The fifth element is a check box labeled "Use Cache?" with a default value of "checked". # On the second row are 6 elements laid out horizontally # The first element is a "Submit" button. # The second element is a FinGPT markdown link which opens a new tab to https://huggingface.co/spaces/FinGPT/FinGPT-Forecaster # The third element is an Article markdown link which opens a new tab to https://docs.google.com/document/d/1WngnKvHFAc8qZEUGt3tBUvFrNFHfeRmHMCX76iD9XMY # The fourth element is a Log markdown link which opens a new tab to https://docs.google.com/spreadsheets/d/19C-EUB3YiLeyC06nJwEJ0mex6PutRfGGG2_ZqkxgAvw/edit?usp=sharing # The fifth element is a Help markdown link which opens a new tab to https://docs.google.com/document/d/128e_RkPohXNduVFvwEY0O0xnNi46lnN8Ad9l7uNBCL8/edit?usp=sharing # When "Submit" is pressed, the application calls strategyAnalysis passing (universe,lags,memberCount,monthsback=12,useCache) which returns a returnStd data frame , monthly Returns data frame and a recommendations data frame. # Please print the recommendations data frame in a dataframe area called "Results". # The second tab is labeled "Strgy rtn vs time" and displays a plotly express line chart where you pass in the monthly Returns data frame. # The third tab is labeled "Strgy rtn vs risk" and displays a plotly express scatter chart where you pass in the returnStd data frame and x="std", y="return",text="ticker". # The fourth tab named "Unvrse Analysis" has 2 rows. # On the first row are 4 elements laid out horizontally # The first element is a multiple select item labeled "universes" with items labeled "D30", "N100", "SP500", "R1000" and "FAANNG". All items are selected. # The second element is a text field labeled "lags(s)" initialized with the string "1,3,6,12;1,3,6,6;4-36". # The third element is a pulldown labeled "U member count" with 6 items labeled 1-6 that defaults to 6. # The fourth element is a text field labeled "U months back" initialized to 12. # On the second row is # a check box labeled "U Use Cache?" with a default value of "checked". # a "U Submit" button. # When "Submit" is pressed, the application calls univeseAnalysis passing (universes,lags,memberCount,monthsback=12,useCache) which returns a aggregatedReturnStd data frame, aggregatedMonthlyReturns data frame # and a aggregatedRecommendations data frame. # Please print the aggregatedRecommendations data frame in a dataframe area called "Results". # The fifth tab is labeled "Unvrse rtn vs time" and displays a plotly express line chart where you pass in the aggregatedMonthlyReturns data frame. # The sixth tab is labeled "Unvrse rtn vs risk" and displays a plotly express scatter chart where you pass in the aggregatedReturnStd data frame and x="std", y="return",text="ticker". # Do not generate a dummy call to strategyAnalysis # Instead create an "from momentumtiming import strategyAnalysis" import. # Do not pass a "key" argument to st.dataframe. # Do not pass x and y arguments to plotly. # Do not generate a target element for the links # And include this entire prompt as a comment in the header of the generated file. import streamlit as st import plotly.express as px #from momentumtiming import strategyAnalysis, universeAnalysis from momentumtiming20240716 import strategyAnalysis, universeAnalysis st.set_page_config(page_title="Momentum analysis tool", layout="wide") tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs(["Strgy Analysis", "Strgy rtn vs time", "Strgy rtn vs risk", "Unvrse Analysis", "Unvrse rtn vs time", "Unvrse rtn vs risk"]) with tab1: col1, col2, col3, col4, col5 = st.columns(5) with col1: universe = st.selectbox("universe", ["D30", "N100", "SP500", "R1000", "FAANNG"], index=4) with col2: lags = st.text_input("lags", value="1,3,6,12") with col3: member_count = st.selectbox("member count", range(1, 7), index=5) with col4: months_back = st.text_input("months back", value="12") with col5: use_cache = st.checkbox("Use Cache?", value=True) col1, col2, col3, col4, col5 = st.columns(5) with col1: submit = st.button("Submit") with col2: st.markdown("[FinGPT](https://huggingface.co/spaces/FinGPT/FinGPT-Forecaster)") with col3: st.markdown("[Article](https://docs.google.com/document/d/1WngnKvHFAc8qZEUGt3tBUvFrNFHfeRmHMCX76iD9XMY)") with col4: st.markdown("[Log](https://docs.google.com/spreadsheets/d/19C-EUB3YiLeyC06nJwEJ0mex6PutRfGGG2_ZqkxgAvw/edit?usp=sharing)") with col5: st.markdown("[Help](https://docs.google.com/document/d/128e_RkPohXNduVFvwEY0O0xnNi46lnN8Ad9l7uNBCL8/edit?usp=sharing)") if submit: returnStd, monthlyReturns, recommendations = strategyAnalysis(universe, lags, member_count, int(months_back), use_cache) st.subheader("Results") st.dataframe(recommendations) with tab2: if 'monthlyReturns' in locals(): fig = px.line(monthlyReturns) st.plotly_chart(fig) with tab3: if 'returnStd' in locals(): #WGP fig = px.scatter(returnStd, hover_data=['ticker']) fig = px.scatter(returnStd, x="std", y="return", text="ticker") st.plotly_chart(fig) with tab4: col1, col2, col3, col4 = st.columns(4) with col1: universes = st.multiselect("universes", ["D30", "N100", "SP500", "R1000", "FAANNG"], default=["D30", "N100", "SP500", "R1000", "FAANNG"]) with col2: u_lags = st.text_input("lags(s)", value="1,3,6,12;1,3,6,6;4-36") with col3: u_member_count = st.selectbox("U member count", range(1, 7), index=5) with col4: u_months_back = st.text_input("U months back", value="12") col1, col2 = st.columns(2) with col1: u_use_cache = st.checkbox("U Use Cache?", value=True) with col2: u_submit = st.button("U Submit") if u_submit: aggregatedReturnStd, aggregatedMonthlyReturns, aggregatedRecommendations = universeAnalysis(universes, u_lags, u_member_count, int(u_months_back), u_use_cache) st.subheader("Results") st.dataframe(aggregatedRecommendations) with tab5: if 'aggregatedMonthlyReturns' in locals(): fig = px.line(aggregatedMonthlyReturns) st.plotly_chart(fig) with tab6: if 'aggregatedReturnStd' in locals(): #WGP fig = px.scatter(aggregatedReturnStd, hover_data=['ticker']) fig = px.scatter(aggregatedReturnStd, x="std", y="return", text="ticker") st.plotly_chart(fig)